package day06.test6;

import java.util.Arrays;

public class test6 {
    public static void main(String[] args) {
        int[] arr ={2,5,6,8,9,1,3,0};
        test6.paixu(arr);
        System.out.println(Arrays.toString(arr));

        int max = test6.max(arr);
        System.out.println("最大值是"+max);
    }
    public static int max(int[] arr)
    {
        int max = arr[0];
        for(int i = 0;i<arr.length;i++)
        {
            if(arr[i]>max)
            {
                max = arr[i];
            }
        }
        return max;
    }
    public static void paixu(int[] arr)
    {
        for(int j = 0;j<arr.length-1;j++)
        {

            for(int i = 0;i<arr.length-1-j;i++)
            {
                if(arr[i] > arr[i+1]) {
                    int tmp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = tmp;
                }
            }
        }
    }
}
